class BaseResponse {
  constructor(data = null, message) {
    if (typeof data === 'string') {
      message = data;
      data = null;
    }

    this.data = data;
    this.message = message;
  }
}

class SuccessResponse extends BaseResponse {
  constructor(data = {}, message = '请求成功') {
    super(data, message);
    this.success = true;
  }
}

class ErrorResponse extends BaseResponse {
  constructor(data, message = '业务失败') {
    super(data, message);
    this.success = false;
  }
}

module.exports = {
  SuccessResponse,
  ErrorResponse
};